package com.dinnerorders.common.utils;

import java.util.Calendar;
import java.util.Date;

/**
 * @author Sergey Nalivko e-mail: snalivko93@gmail.com
 */
public class DateUtils {
    public static Date getCurrentWeekStartDate() {
        return getWeekStartDate(Calendar.getInstance().getTime());
    }

    public static Date getWeekStartDate(Date time) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(time);
        calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        return time;
    }

    public static Date getCurrentWeekEndDate() {
        return getWeekEndDate(Calendar.getInstance().getTime());
    }

    public static Date getWeekEndDate(Date time) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(time);
        calendar.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
        return time;
    }
}
